#include "PopupManager.h"
#include "../Utils/Utils.h"

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= PopupManager =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Popup::Popup()
	: m_descriptionLabel(NULL),
	m_popupIcon(NULL)
{}

Popup::~Popup()
{
	if(m_popupIcon)
		delete m_popupIcon;
}

Popup::Popup(const gchar *popupIconPath, const gchar *descriptionText)
{
	Popup();

	m_popupIcon			= gtk_image_new_from_file(popupIconPath);
	m_descriptionLabel	= gtk_label_new(descriptionText);
}
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= PopupManager =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PopupManager::PopupManager()
	: m_window(gtk_window_new(GTK_WINDOW_TOPLEVEL)),
	m_popup(NULL), m_background(create_pixbuf("popup_bg.png")),
	m_hbox(gtk_hbox_new(TRUE, 1))
	//m_hbox(gtk_fixed_new())
{
	// Screan
	GdkScreen* screen = NULL;
	screen = gtk_window_get_screen(GTK_WINDOW(m_window));
	int height = gdk_screen_get_height(screen);
	int width = gdk_screen_get_width(screen);
	//GtkWindowPosition pos = 

	// Window
	gtk_window_set_decorated(GTK_WINDOW(m_window), FALSE);
	gtk_window_set_default_size(GTK_WINDOW(m_window), 350, 100);

	GdkPixmap	*backgroundPixmap;
	GtkStyle	*style; 
	gdk_pixbuf_render_pixmap_and_mask (m_background, &backgroundPixmap, NULL, 0); 
	style = gtk_style_new ();
	style->bg_pixmap[0] = backgroundPixmap; 
	
	gtk_widget_set_style (GTK_WIDGET(m_window), GTK_STYLE(style)); 
	//gdk_window_set_back_pixmap((GTK_WINDOW(m_window), backgroundPixmap);
	//gtk_container_add(GTK_CONTAINER(m_window), m_background);
	//gtk_widget_set_usize(m_background, 10, 10);

	gtk_container_add(GTK_CONTAINER(m_window), m_hbox);

	gtk_window_move(GTK_WINDOW(m_window), (width - 350), (height - 100));

}

PopupManager::~PopupManager()
{

}

void PopupManager::showPopup(Popup* popup)
{
	m_popup = popup;

	

	gtk_box_pack_start(GTK_BOX(m_hbox), m_popup->m_popupIcon, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(m_hbox), m_popup->m_descriptionLabel, TRUE, TRUE, 0);

	gtk_widget_show_all(m_window);
}